package com.gxa.service.impl.fwgl.yhgl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.gxa.mapper.fwgl.yhgl.OldInfoMapper;
import com.gxa.pojo.dto.fwgl.OldInfoDto;
import com.gxa.pojo.entity.fwgl.TOldinfo;
import com.gxa.service.fwgl.yhgl.OldInfoService;
import com.gxa.utils.QueryResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * @Author：lizhijun
 * @Package：{PROJECT_NAME}
 * @name：{DATE} {NAME}
 */
@Service
public class OldInfoServiceImpl implements OldInfoService {
    @Resource
    private OldInfoMapper oldInfoMapper;

    @Override
    public QueryResult queryAll(OldInfoDto oldInfoDto) {
        Page<TOldinfo> page = PageHelper.startPage(oldInfoDto.getPage(),oldInfoDto.getLimit());
        List<TOldinfo> oldinfoList = oldInfoMapper.queryAll(oldInfoDto);
        QueryResult queryResult = new QueryResult();
        queryResult.setCount(page.getTotal());
        queryResult.setData(oldinfoList);
        return queryResult;
    }



    @Override
    public void add(TOldinfo oldinfo) {
    oldInfoMapper.insertoldInfo(oldinfo);
    }

    @Override
    public void update(TOldinfo oldinfo) {
     oldInfoMapper.updateoldInfo(oldinfo);
    }

    @Override
    public void delete(List<Integer> ids) {
        System.out.println("========="+ ids);
   oldInfoMapper.deleteoldInfo(ids);
    }

    //查看单个数据的详情
    @Override
    public QueryResult queryById(int id) {
        List<TOldinfo> oldinfoList = oldInfoMapper.queryById(id);
        QueryResult queryResult = new QueryResult();
        queryResult.setData(oldinfoList);
        return queryResult;
    }

    @Override
    public TOldinfo findByName(String patientName) {
        return oldInfoMapper.queryByPatientName(patientName);
    }
}
